const mogodb = require('mongoose')
import conf from '../conf/config'
import wx from '../wechat-lib/index'

const Token = mogodb.model('token');

const wechatConfig = {
    wechat:{
        appID:conf.appID,
        appSecret:conf.appSecret,
        getAccessToken: async () => await Token.getAccessToken(),
        saveAccessToken:async (data)=>await Token.saveAccessToken(data)
    }
}


export const getWechatAccessToken=()=>{
    const wechatClient = new wx(wechatConfig.wechat)
    return wechatClient
}

getWechatAccessToken()

